package ch12;

class ThreadEx13 {
	public static void main(String args[]) {
		Data d = new Data();
		MyThreadEx14 t1 = new MyThreadEx14(d);
		MyThreadEx14 t2 = new MyThreadEx14(d);

		t1.start();
		t2.start();
	}
}

class Data {
	int iv = 0;
}

class MyThreadEx14 extends Thread {
	Data d;

	MyThreadEx14(Data d) {
		this.d = d;
	}

	public void run() {
		int lv = 0;

		while (lv < 3) {
			System.out.println(getName() + " Local Var: " + ++lv);
			System.out.println(getName() + " Instance Var :" + ++d.iv);
			System.out.println();
		}
	}
}
/*
Thread-0 Local Var: 1
Thread-0 Instance Var :1

Thread-0 Local Var: 2
Thread-0 Instance Var :2

Thread-0 Local Var: 3
Thread-0 Instance Var :3

Thread-1 Local Var: 1
Thread-1 Instance Var :4

Thread-1 Local Var: 2
Thread-1 Instance Var :5

Thread-1 Local Var: 3
Thread-1 Instance Var :6

*/